package com.bbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bbs.entity.BBSPostCategory;
import com.bbs.mapper.IBBSPostCategoryMapper;
import com.bbs.service.IBBSPostCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PackageName: com.bbs.service.impl
 * @ClassName: BBSPostCategoryServiceImpl
 * @Description:
 * @Author: Rambo
 * @Data: 2024/6/4 15:48
 */
@Service
public class BBSPostCategoryServiceImpl implements IBBSPostCategoryService {
    @Autowired
    IBBSPostCategoryMapper bbsPostCategoryMapper;

    /**
     * 查询所有分类信息
     * @return
     */
    @Override
    public List<BBSPostCategory> getBBSPostCategories() {
        return bbsPostCategoryMapper.selectList(null);
    }

    /**
     * 根据分类ID查询分类信息
     * @param categoryId 分类ID
     * @return
     */
    @Override
    public BBSPostCategory selectById(Integer categoryId) {
        return bbsPostCategoryMapper.selectOne(
                new LambdaQueryWrapper<BBSPostCategory>()
                        .eq(BBSPostCategory::getCategoryId, categoryId)
        );
    }
}
